<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jq/jquery-1.11.1.js"></script>
<script type="text/javascript">
$(function(){
	$("#check").click(function(){
		$.post("CheckIt",{username:$("#username").val()},function(data){
			var s=data.split("$");
			$("#status").val(s[0]);
			$("#info").html(s[1]);	
		});
	});	
	$("#btn").click(function(){
		if($("#status").val()==0){
			$("#info").html("请先检测用户名！");
			return false;
		}
		if($("#status").val()==1){
			$("#info").html("用户名重复，请重新填写并检查用户名！");
			$("#status").val(0);
			return false;
		}
		return true;
	});
});
</script>
</head>
<body>
<form action="welcome.jsp" method="post">
<table id="f1">
<tr><td>用户名</td><td><input type="text" name="username" id="username"></td></tr>
<tr><td>密码</td><td><input type="password" name="pwd"></td><tr>
<tr><td><input type="button" name="check" id="check" value="检查用户"></td>
<td><input type="submit" name="btn" id="btn" value="提交"></td></tr>
</table>
</form>
<input type="hidden" id="status" value="0">
<div id="info"></div>
</body>
</html>